$(function(){
    init();
})

function init(){
    var begin = $("#begin").val();
    var end = $("#end").val();
    if( isIntNum(begin)==isIntNum(end) && isIntNum(begin)){
        red01(begin,end);
        red02(begin,end);
        red03(begin,end);
        red04(begin,end);
        red05(begin,end);
        blue01(begin,end);
        blue02(begin,end);
    }else{
        alert("请输入正确的期数");
    }
}

//获取1号球
function red01(begin,end) {
    $.ajax({
        type: "GET",
        url: "../analyse/red01",
        data: {
            begin:begin,
            end:end
        },
        dataType: "json",
        success: function(data){
            if(null != data && data != ''){
                var num = new Array();
                var red = new Array();

                for(var key in data){
                    num.push(data[key].num);
                    red.push(data[key].red_01);
                }
                initBar(red,num,"1号球","red_01","#CD3333");
            }
        }
    });
}

//获取2号球
function red02(begin,end) {
    $.ajax({
        type: "GET",
        url: "../analyse/red02",
        data: {
            begin:begin,
            end:end
        },
        dataType: "json",
        success: function(data){
            if(null != data && data != ''){
                var num = new Array();
                var red = new Array();

                for(var key in data){
                    num.push(data[key].num);
                    red.push(data[key].red_02);
                }
                initBar(red,num,"2号球","red_02","#CD3333");
            }
        }
    });
}

//获取2号球
function red03(begin,end) {
    $.ajax({
        type: "GET",
        url: "../analyse/red03",
        data: {
            begin:begin,
            end:end
        },
        dataType: "json",
        success: function(data){
            if(null != data && data != ''){
                var num = new Array();
                var red = new Array();

                for(var key in data){
                    num.push(data[key].num);
                    red.push(data[key].red_03);
                }
                initBar(red,num,"3号球","red_03","#CD3333");
            }
        }
    });
}

//获取4号球
function red04(begin,end) {
    $.ajax({
        type: "GET",
        url: "../analyse/red04",
        data: {
            begin:begin,
            end:end
        },
        dataType: "json",
        success: function(data){
            if(null != data && data != ''){
                var num = new Array();
                var red = new Array();

                for(var key in data){
                    num.push(data[key].num);
                    red.push(data[key].red_04);
                }
                initBar(red,num,"4号球","red_04","#CD3333");
            }
        }
    });
}

//获取5号球
function red05(begin,end) {
    $.ajax({
        type: "GET",
        url: "../analyse/red05",
        data: {
            begin:begin,
            end:end
        },
        dataType: "json",
        success: function(data){
            if(null != data && data != ''){
                var num = new Array();
                var red = new Array();

                for(var key in data){
                    num.push(data[key].num);
                    red.push(data[key].red_05);
                }
                initBar(red,num,"5号球","red_05","#CD3333");
            }
        }
    });
}

//获取蓝色1号球
function blue01(begin,end) {
    $.ajax({
        type: "GET",
        url: "../analyse/blue01",
        data: {
            begin:begin,
            end:end
        },
        dataType: "json",
        success: function(data){
            if(null != data && data != ''){
                var num = new Array();
                var blue = new Array();

                for(var key in data){
                    num.push(data[key].num);
                    blue.push(data[key].blue_01);
                }
                initBar(blue,num,"蓝球1号球","blue_01","#5CACEE");
            }
        }
    });
}

//获取蓝色2号球
function blue02(begin,end) {
    $.ajax({
        type: "GET",
        url: "../analyse/blue02",
        data: {
            begin:begin,
            end:end
        },
        dataType: "json",
        success: function(data){
            if(null != data && data != ''){
                var num = new Array();
                var blue = new Array();

                for(var key in data){
                    num.push(data[key].num);
                    blue.push(data[key].blue_02);
                }
                initBar(blue,num,"蓝球2号球","blue_02","#5CACEE");
            }
        }
    });
}